import React, {Component} from 'react'
class WrappedComponent extends Component {
  constructor (props) {
    super(props)
  }
  render () {
    const {user, name, age} = this.props
    return (
      <div>
        <p>user: {user}</p>
        <p>name: {name}</p>
        <p>age: {age}</p>
      </div>
    )
  }
}

function removeUserProp (WrappedComponent) {
  return class NewComponent extends WrappedComponent {
    constructor (props) {
      super(props)
    }
    shouldComponentUpdate () { // 继承式的高阶组件优势在于可以重定义组件的声明周期函数
      console.log('shouldComponentUpdate')
    }
    render () {
      const {user, ...otherProps} = this.props
      this.props = otherProps // 如果要操作props使用代理式的高阶组件
      return super.render()
    }
  }
}
export default removeUserProp(WrappedComponent)